package com.mew.auc.service;

import com.mew.common.entity.mail.Accessory;
import com.mew.common.entity.mail.Mail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MailUtilService {
    @Autowired
    private MailMapper mailMapper;
    @Autowired
    private AccessoryMapper accessoryMapper;

    @Transactional(rollbackFor = Exception.class)
    /**
     * 插入邮件
     */
    public void insertMail(Mail mail, Accessory... accessory){
        mailMapper.insert(mail);
        for (Accessory a : accessory) {
            a.setMailId(mail.getId());
            accessoryMapper.insert(a);
        }
    }
}
